<template>
    <div class="page login-view">
        <wv-header title="密码找回" fixed>
            <div class="btn-menu" slot="right">
                <span class="register-btn" @click="$router.push({name: 'login'})">登录</span>
            </div>
        </wv-header>
        <div class="main-header-fixed">
            <div class="login-wrapper">
                <wv-group >
                    <wv-input type="email" label="电子邮箱" placeholder="请输入电子邮箱" v-model="fields.email" required></wv-input>
                </wv-group>
                <wv-button type="primary" @click="findPassword">找回密码</wv-button>
            </div>
        </div>
    </div>
</template>

<script>
    import util from '@/libs/util';
    import storage from '@/libs/storage';
    import config from '@/config/';
    export default {
        data () {
            return {
                fields: {
                    email: '',
                }
            }
        },

        methods: {
            findPassword () {
                util.ajax.post('/password/email', this.fields).then((resp) => {
                    if (resp.data.status == false) {
                        this.$root.topTips(resp.data.message);
                    } else {
                        this.$root.toast(resp.data.message);

                        // 登录成功进入首页
                        this.$router.push({
                            name: 'login'
                        });
                    }
                }).catch((e) => {
                    util.handleApiException(e, this, '找回密码失败');
                });
            }
        }
    }
</script>

<style scoped lang="scss">

</style>